home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-13 | 27.1 KB | 1,112 lines | [TEXT/EDIT] |
- Only in /users/prof/colnet/SmallEiffel/lib_std: arguments.e
- diff -r lib_std/array.e /users/prof/colnet/SmallEiffel/lib_std/array.e
- 37,38c37,38
- < if storage /= Void then
- < c_inline_c("free(C->_storage);");
- ---
- > if storage.is_not_void then
- > free_pointer(storage);
- 43d42
- < storage := Void;
- 46,47c45
- < c_inline_c("C->_storage=malloc%
- < %((size_t)((C->_capacity)*sizeof(*(C->_storage))));");
- ---
- > storage := malloc(capacity);
- 80,81c78,79
- < if storage /= Void then
- < c_inline_c("free(C->_storage);");
- ---
- > if storage.is_not_void then
- > free_pointer(storage);
- 83c81,82
- < c_inline_c("memcpy(C,_other,sizeof(*C));free(_other);");
- ---
- > standard_copy(other);
- > other.free_array;
- 88c87
- < infix "@", item (index: INTEGER): E is
- ---
- > item, infix "@" (index: INTEGER): E is
- 90,94c89,91
- < check
- < storage /= Void;
- < capacity >= (upper - lower + 1);
- < end;
- < c_inline_c("R=(C->_storage)[a1-(C->_lower)];")
- ---
- > if storage = Void then end;
- > if lower = Void then end;
- > c_inline_c("R=(((C->_storage))[a1-(C->_lower)]);")
- 102c99,101
- < c_inline_c("(C->_storage)[a2-(C->_lower)]=a1;");
- ---
- > if storage = Void then end;
- > if lower = Void then end;
- > c_inline_c("((C->_storage)[a2-(C->_lower)])=a1;");
- 205a205
- > if storage = Void then end;
- 207,209c207,209
- < capacity := capacity + 16;
- < if capacity = 16 then
- < c_inline_c("C->_storage=malloc(16*sizeof(*(C->_storage)));");
- ---
- > if capacity = 0 then
- > capacity := 16;
- > storage := malloc(capacity);
- 211,212c211,212
- < c_inline_c("C->_storage=realloc(C->_storage,%
- < %((C->_capacity)*sizeof(*(C->_storage))));");
- ---
- > capacity := capacity + 16;
- > storage := realloc(storage,capacity);
- 322c322,353
- <
- ---
- >
- > feature {NONE}
- >
- > malloc(size: INTEGER): POINTER is
- > require
- > size > 0
- > do
- > c_inline_c("R=malloc((size_t)(a1*sizeof(*(C->_storage))));");
- > end;
- >
- > realloc(pointer: POINTER; size: INTEGER): POINTER is
- > require
- > size > 0
- > do
- > c_inline_c("R=realloc(a1,%
- > %((size_t)(a2*sizeof(*(C->_storage)))));");
- > end;
- >
- > free_pointer(p: POINTER) is
- > require
- > p.is_not_void
- > external "C"
- > alias "free"
- > end;
- >
- > feature {ARRAY}
- >
- > free_array is
- > external "CWC"
- > alias "free"
- > end;
- >
- 326c357,359
- <
- ---
- >
- > capacity > 0 implies storage.is_not_void;
- >
- diff -r lib_std/array.e /users/prof/colnet/SmallEiffel/lib_std/array.elib_std/boolean.e /users/prof/colnet/SmallEiffel/lib_std/boolean.e
- 20c20,21
- < external "CSE"
- ---
- > do
- > Result := Current and then other;
- 35c36,37
- < external "CSE"
- ---
- > do
- > Result := Current or else other;
- 55c57,61
- < external "CSE"
- ---
- > do
- > if Current then
- > else
- > Result := true;
- > end;
- diff -r lib_std/boolean.e /users/prof/colnet/SmallEiffel/lib_std/boolean.elib_std/boolean_ref.e /users/prof/colnet/SmallEiffel/lib_std/boolean_ref.e
- 11,12c11
- < creation {ANY}
- < make
- ---
- > creation make
- 14c13
- < feature {ANY}
- ---
- > feature
- 22a22,28
- > end;
- >
- > feature
- >
- > set_item(value: like item) is
- > do
- > item := value;
- diff -r lib_std/boolean_ref.e /users/prof/colnet/SmallEiffel/lib_std/boolean_ref.elib_std/character.e /users/prof/colnet/SmallEiffel/lib_std/character.e
- 22c22
- < infix "<"(other: CHARACTER): BOOLEAN is
- ---
- > infix "<" (other: CHARACTER): BOOLEAN is
- 24c24,25
- < external "CSE"
- ---
- > do
- > Result := code < other.code;
- 29c30,31
- < external "CSE"
- ---
- > do
- > Result := code <= other.code;
- 34c36,37
- < external "CSE"
- ---
- > do
- > Result := code > other.code;
- 39c42,43
- < external "CSE"
- ---
- > do
- > Result := code >= other.code;
- 62c66
- < same_as(other : CHARACTER): BOOLEAN is
- ---
- > same_as(other: CHARACTER): BOOLEAN is
- 65c69,80
- < Result := to_lower = other.to_lower;
- ---
- > if Current = other then
- > Result := true;
- > else
- > inspect
- > code
- > when 65 .. 90 then
- > Result := Current = other.to_upper;
- > when 97 .. 122 then
- > Result := Current = other.to_lower;
- > else
- > end;
- > end;
- diff -r lib_std/character.e /users/prof/colnet/SmallEiffel/lib_std/character.elib_std/character_ref.e /users/prof/colnet/SmallEiffel/lib_std/character_ref.e
- 8,9c8
- < creation {ANY}
- < make
- ---
- > creation make
- 11c10
- < feature {ANY}
- ---
- > feature
- 19a19,25
- > feature
- >
- > set_item(value: like item) is
- > do
- > item := value;
- > end;
- >
- diff -r lib_std/character_ref.e /users/prof/colnet/SmallEiffel/lib_std/character_ref.elib_std/double_ref.e /users/prof/colnet/SmallEiffel/lib_std/double_ref.e
- 17,18c17
- < creation {ANY}
- < make
- ---
- > creation make
- 20c19
- < feature {ANY}
- ---
- > feature
- 28a28,34
- > feature
- >
- > set_item(value: like item) is
- > do
- > item := value;
- > end;
- >
- diff -r lib_std/double_ref.e /users/prof/colnet/SmallEiffel/lib_std/double_ref.elib_std/fixed_array.e /users/prof/colnet/SmallEiffel/lib_std/fixed_array.e
- 20c20
- < make, resize
- ---
- > make, resize, from_collection
- 41a42,43
- > local
- > model: like item;
- 43,44c45,48
- < if storage /= Void then
- < c_inline_c("free(C->_storage);");
- ---
- > if storage.is_not_void then
- > storage := realloc(storage,size,model);
- > else
- > storage := malloc(size,model);
- 46,47d49
- < c_inline_c("C->_storage=malloc(((size_t)%
- < %sizeof(*(C->_storage))*a1));");
- 53a56,74
- >
- > from_collection(cltn: COLLECTION[E]) is
- > local
- > fa_index, cltn_index: INTEGER;
- > do
- > from
- > make(cltn.count);
- > fa_index := upper;
- > cltn_index := cltn.upper;
- > until
- > fa_index < 0
- > loop
- > put(cltn.item(cltn_index),fa_index);
- > cltn_index := cltn_index - 1;
- > fa_index := fa_index - 1;
- > end;
- > ensure
- > count = cltn.count
- > end;
- 59c80,81
- < c_inline_c("R=(C->_storage)[a1];")
- ---
- > if storage = Void then end;
- > c_inline_c("R=((C->_storage)[a1]);")
- 66c88
- < c_inline_c("(C->_storage)[a2]=a1;");
- ---
- > c_inline_c("((C->_storage)[a2])=a1;");
- 73,76d94
- < if storage /= Void then
- < c_inline_c("free(C->_storage);");
- < storage := Void;
- < end;
- 157c175,191
- <
- ---
- >
- > feature {NONE}
- >
- > malloc(size: INTEGER; model: like item): POINTER is
- > require
- > size > 0
- > do
- > c_inline_c("R=malloc((size_t)(a1*sizeof(a2)));");
- > end;
- >
- > realloc(pointer: POINTER; size: INTEGER; model: like item): POINTER is
- > require
- > size > 0
- > do
- > c_inline_c("R=realloc(a1,(size_t)(a2*sizeof(a3)));");
- > end;
- >
- diff -r lib_std/fixed_array.e /users/prof/colnet/SmallEiffel/lib_std/fixed_array.elib_std/general.e /users/prof/colnet/SmallEiffel/lib_std/general.e
- 123c123
- < -- ELKS problem for expanded target.
- ---
- > -- ELKS95 bug for expanded target.
- 158c158,159
- < same_type: Result implies same_type(other);
- ---
- > -- *** same_type: Result implies same_type(other);
- > -- ELKS95 bug for expanded target.
- 165,166c166,167
- < -- Void if `other' is Void; otherwise new object
- < -- equal to `other'.
- ---
- > -- When argument `other' is Void, call `twin' otherwise
- > -- return Void.
- 169c170,190
- < c_inline_c("R=(T0 *)se_new(a1->id);");
- ---
- > Result := other.twin;
- > end;
- > ensure
- > equal: equal(Result,other);
- > end;
- >
- > frozen twin: like Current is
- > -- Return an initialized new object using target as model.
- > -- Result as the same `generating_type' as the target of the
- > -- call. Before to be returned, the corresponding `copy' feature
- > -- is called.
- > do
- > if is_expanded_type then
- > if is_basic_expanded_type then
- > Result := Current;
- > else
- > Result := Current;
- > Result.copy(Current);
- > end;
- > else
- > c_inline_c("R=(T0 *)se_new(C->id);");
- 171c192
- < Result.copy(other);
- ---
- > Result.copy(Current);
- 175c196
- < equal: equal(Result,other);
- ---
- > equal: Result.is_equal(Current);
- 345c366
- < external "CSE"
- ---
- > do
- 352a374,375
- > local
- > p: POINTER;
- 354c377
- < path.extend('%U');
- ---
- > p := path.to_external;
- 356c379
- < "{FILE *f=fopen(((T7 *)a1)->_storage,%"r%");%N%
- ---
- > "{FILE *f=fopen(((char*)_p),%"r%");%N%
- 359d381
- < path.remove_last(1);
- 364a387,388
- > local
- > p: POINTER;
- 366,368c390,391
- < path.extend('%U');
- < c_inline_c("remove(((T7 *)a1)->_storage);");
- < path.remove_last(1);
- ---
- > p := path.to_external;
- > c_inline_c("remove(((char*)_p));");
- 374a398,399
- > local
- > op, np: POINTER;
- 376,380c401,403
- < old_path.extend('%U');
- < new_path.extend('%U');
- < c_inline_c("rename(((T7 *)a1)->_storage,((T7 *)a2)->_storage);");
- < old_path.remove_last(1);
- < new_path.remove_last(1);
- ---
- > op := old_path.to_external;
- > np := new_path.to_external;
- > c_inline_c("rename(((char*)_op),((char*)_np));");
- 388c411,412
- < external "CSE"
- ---
- > do
- > Result := command_arguments.upper;
- 399c423,424
- < external "CSE"
- ---
- > do
- > Result := command_arguments.item(i);
- 402a428,450
- >
- > frozen command_arguments: ARRAY[STRING] is
- > -- ***** FIXED_ARRAY[STRING]
- > -- Give an acces to arguments command line including the
- > -- command name at index 0.
- > local
- > i: INTEGER;
- > arg: STRING;
- > once
- > from
- > c_inline_c("_i=se_argc-1;");
- > !!Result.make(0,i);
- > until
- > i < 0
- > loop
- > c_inline_c("_arg=((T0*)e2s(se_argv[_i]));");
- > Result.put(arg,i);
- > i := i - 1;
- > end;
- > ensure
- > Result.lower = 0; -- ***** FIXED_ARRAY
- > not Result.empty
- > end;
- 409a458,459
- > local
- > p: POINTER;
- 411,414c461,465
- < name.extend('%U');
- < c_inline_c("R=((T0 *)getenv(((T7 *)a1)->_storage));%N%
- < %if (R) R=((T0 *)e2s((char *)R));")
- < name.remove_last(1);
- ---
- > p := name.to_external;
- > c_inline_c("_p=((void*)getenv((char*)_p));");
- > if p.is_not_void then
- > c_inline_c("R=(T0*)e2s((char*)_p);");
- > end;
- 423a475,476
- > local
- > p: POINTER;
- 425,427c478,479
- < cmd.extend('%U');
- < c_inline_c("system(((T7 *)a1)->_storage);");
- < cmd.remove_last(1);
- ---
- > p := cmd.to_external;
- > c_inline_c("system(((char*)_p));");
- 519c571
- < -- Statically computed by SmallEiffel.
- ---
- > -- Target is not evaluated (Statically computed).
- 521d572
- < -- Target is not evaluated.
- 525a577,586
- > frozen is_basic_expanded_type: BOOLEAN is
- > -- Target is not evaluated (Statically computed).
- > -- Result is true if target static type is one of the
- > -- following types : BOOLEAN, CHARACTER, INTEGER, REAL,
- > -- DOUBLE or POINTER.
- > external "CSE"
- > ensure
- > Result implies is_expanded_type
- > end;
- >
- 529,530c590
- < -- The result is the C sizeof of the corresponding
- < -- struct or basic object.
- ---
- > -- The result is given in number of CHARACTER.
- 552a613,625
- > end;
- >
- > feature -- WARNING: For SmallEiffel Gurus's only.
- > -- Internal implementation of the SmallEiffel
- > -- debugger/interpretor (command `eval').
- >
- > eval_read_attribute(name: STRING; dest: POINTER) is do end;
- >
- > eval_write_attribute(name: STRING; source: POINTER) is do end;
- >
- > frozen eval_virtual_machine: EVAL_VIRTUAL_MACHINE is
- > once
- > !!Result.make;
- diff -r lib_std/general.e /users/prof/colnet/SmallEiffel/lib_std/general.elib_std/integer.e /users/prof/colnet/SmallEiffel/lib_std/integer.e
- 11,13c11,14
- < infix "+", infix "-", infix "*", infix "/", infix "\\", infix "//",
- < infix "^", infix "<", infix "<=", infix ">", infix ">=", compare,
- < prefix "-", prefix "+", hash_code, one, zero, print_on
- ---
- > infix "+", infix "-", infix "*", infix "/", infix "\\",
- > infix "//", infix "^", infix "<", infix "<=", infix ">",
- > infix ">=", compare, prefix "-", prefix "+", hash_code,
- > one, zero, print_on
- 74c75
- < -- Is Current smaller than `other'?
- ---
- > -- Is 'Current' strictly less than 'other'?
- 79c80
- < -- Is Current smaller or equal to `other'?
- ---
- > -- Is 'Current' less or equal 'other'?
- 84c85
- < -- Is Current greater than `other'?
- ---
- > -- Is 'Current' strictly greater than 'other'?
- 89c90
- < -- Is Current greater or equal to `other'?
- ---
- > -- Is 'Current' greater or equal than 'other'?
- 134c135
- < Result := to_real.sqrt;
- ---
- > Result := to_double.sqrt;
- 176a178,184
- > to_boolean: BOOLEAN is
- > do
- > if Current /= 0 then
- > Result := true;
- > end;
- > end;
- >
- 295c303,306
- < tmp_string: STRING is "0000000000000000000";
- ---
- > tmp_string: STRING is
- > once
- > !!Result.make(128);
- > end;
- diff -r lib_std/integer.e /users/prof/colnet/SmallEiffel/lib_std/integer.elib_std/integer_ref.e /users/prof/colnet/SmallEiffel/lib_std/integer_ref.e
- 17,18c17
- < creation {ANY}
- < make
- ---
- > creation make
- 20c19
- < feature {ANY}
- ---
- > feature
- 28a28,34
- > feature
- >
- > set_item(value: like item) is
- > do
- > item := value;
- > end;
- >
- diff -r lib_std/integer_ref.e /users/prof/colnet/SmallEiffel/lib_std/integer_ref.elib_std/platform.e /users/prof/colnet/SmallEiffel/lib_std/platform.e
- 8,9c8
- <
- < feature {ANY}
- ---
- > feature -- Maximum :
- 11c10,16
- < Maximum_character_code : INTEGER is 255
- ---
- > Maximum_character_code : INTEGER is
- > -- Largest supported code for CHARACTER values.
- > once
- > c_inline_c("R=CHAR_MAX;");
- > ensure
- > meaningful: Result >= 127
- > end;
- 13c18,24
- < end -- class PLATFORM
- ---
- > Maximum_integer: INTEGER is
- > -- Largest supported value of type INTEGER.
- > once
- > c_inline_c("R=INT_MAX;");
- > ensure
- > meaningful: Result >= 0
- > end;
- 14a26,127
- > Maximum_real: REAL is
- > -- Largest supported value of type REAL.
- > once
- > c_inline_c("R=FLT_MAX;");
- > ensure
- > meaningful: Result >= 0.0
- > end;
- >
- > Maximum_double: DOUBLE is
- > -- Largest supported value of type DOUBLE.
- > once
- > c_inline_c("R=DBL_MAX;");
- > ensure
- > meaningful: Result >= 0.0
- > end;
- >
- > feature -- Minimum :
- >
- > Minimum_character_code: INTEGER is
- > -- Smallest supported code for CHARACTER values.
- > once
- > c_inline_c("R=CHAR_MIN;");
- > ensure
- > meaningful: Result <= 0
- > end;
- >
- > Minimum_integer: INTEGER is
- > -- Smallest supported value of type INTEGER.
- > once
- > c_inline_c("R=INT_MIN;");
- > ensure
- > meaningful: Result <= 0
- > end;
- >
- > Minimum_double: DOUBLE is
- > -- Smallest supported value of type DOUBLE.
- > once
- > Result := - Maximum_double;
- > ensure
- > meaningful: Result <= 0
- > end;
- >
- > Minimum_real: REAL is
- > -- Smallest supported value of type REAL.
- > once
- > Result := - Maximum_real;
- > ensure
- > meaningful: Result <= 0
- > end;
- >
- > feature -- Bits :
- >
- > Boolean_bits: INTEGER is
- > -- Number of bits in a value of type BOOLEAN.
- > once
- > c_inline_c("R=(CHAR_BIT*sizeof(int));");
- > ensure
- > meaningful: Result >= 1
- > end;
- >
- > Character_bits: INTEGER is
- > -- Number of bits in a value of type CHARACTER.
- > once
- > c_inline_c("R=CHAR_BIT;");
- > ensure
- > meaningful: Result >= 1;
- > large_enough: (2^Result) >= Maximum_character_code;
- > end;
- >
- > Integer_bits: INTEGER is
- > -- Number of bits in a value of type INTEGER.
- > once
- > c_inline_c("R=(CHAR_BIT*sizeof(int));");
- > ensure
- > meaningful: Result >= 1;
- > end;
- >
- > Real_bits: INTEGER is
- > -- Number of bits in a value of type DOUBLE.
- > once
- > c_inline_c("R=(CHAR_BIT*sizeof(float));");
- > ensure
- > meaningful: Result >= 1;
- > meaningful: Result >= Real_bits;
- > end;
- >
- > Double_bits: INTEGER is
- > -- Number of bits in a value of type DOUBLE.
- > once
- > c_inline_c("R=(CHAR_BIT*sizeof(double));");
- > ensure
- > meaningful: Result >= 1;
- > meaningful: Result >= Real_bits;
- > end;
- >
- > Pointer_bits: INTEGER is
- > -- Number of bits in a value of type REAL.
- > once
- > c_inline_c("R=(CHAR_BIT*sizeof(char *));");
- > end;
- >
- > end -- PLATFORM
- diff -r lib_std/platform.e /users/prof/colnet/SmallEiffel/lib_std/platform.elib_std/pointer.e /users/prof/colnet/SmallEiffel/lib_std/pointer.e
- 9,12c9,18
- < -- Note : corresponding C type is usually "void *".
- < -- In type STRING, POINTER is mapped "char *".
- < -- In type ARRAY and FIXED_ARRAY, POINTER is mapped as the
- < -- C type of the generic actual argument.
- ---
- > -- Note : corresponding C type is mapped as "void *" except for
- > -- source files "string.e", "array.e" and "fixed_array.e".
- > -- In file "string.e", type POINTER is simply mapped as
- > -- the usual C type "char*".
- > -- In files "array.e" and "fixed_array.e", the mapping depends
- > -- on the actual generic type. When the actual generic type
- > -- is a reference type, POINTER is mapped as C type "T0 **".
- > -- When the actual type is an expanded type, POINTER is mapped
- > -- as "<Ti>*" where <Ti> is the corresponding type of expanded
- > -- actual generic argument.
- 13a20
- >
- 19a27,40
- >
- > is_not_void: BOOLEAN is
- > -- Is the external POINTER a non Void pointer ?
- > --
- > -- NOTE: as POINTER is an expanded class, the Eiffel
- > -- test Current /= Void is always true.
- > --
- > external "CSE"
- > end;
- >
- > is_void: BOOLEAN is
- > do
- > Result := not is_not_void;
- > end;
- diff -r lib_std/pointer.e /users/prof/colnet/SmallEiffel/lib_std/pointer.elib_std/pointer_ref.e /users/prof/colnet/SmallEiffel/lib_std/pointer_ref.e
- 10c10,15
- < end -- class INTEGER_REF
- ---
- > set_item(value: like item) is
- > do
- > item := value;
- > end;
- >
- > end -- POINTER_REF
- diff -r lib_std/pointer_ref.e /users/prof/colnet/SmallEiffel/lib_std/pointer_ref.elib_std/real_ref.e /users/prof/colnet/SmallEiffel/lib_std/real_ref.e
- 17,18c17
- < creation {ANY}
- < make
- ---
- > creation make
- 20c19
- < feature {ANY}
- ---
- > feature
- 28a28,34
- > feature
- >
- > set_item(value: like item) is
- > do
- > item := value;
- > end;
- >
- diff -r lib_std/real_ref.e /users/prof/colnet/SmallEiffel/lib_std/real_ref.elib_std/std_error.e /users/prof/colnet/SmallEiffel/lib_std/std_error.e
- 39c39
- < feature {NONE}
- ---
- > feature {RUN_FEATURE}
- diff -r lib_std/std_error.e /users/prof/colnet/SmallEiffel/lib_std/std_error.elib_std/std_file.e /users/prof/colnet/SmallEiffel/lib_std/std_file.e
- 49,50c49
- < -- NOTE: use only a few basic ANSI C functions.
- < -- Try to use a as less as possible external C calls.
- ---
- > -- NOTE: use only a few basic external C calls.
- 58a58,59
- > local
- > pf, pm: POINTER;
- 60,65c61,63
- < f.extend('%U');
- < m.extend('%U');
- < c_inline_c("R=(T0 *)fopen(((Tstring *)a1)->_storage,%
- < %((Tstring *)a2)->_storage);");
- < f.remove_last(1);
- < m.remove_last(1);
- ---
- > pf := f.to_external;
- > pm := m.to_external;
- > c_inline_c("R=(void*)fopen(((char*)_pf),((char*)_pm));");
- 70d67
- < alias "fclose"
- 71a69,72
- >
- > fputc(c: CHARACTER; stream_pointer: POINTER): CHARACTER is
- > external "C"
- > end;
- 72a74,83
- > fgetc(stream_pointer : POINTER): CHARACTER is
- > -- Result is of type CHARACTER because a int is a char !
- > external "C"
- > end;
- >
- > feof(stream_ptr: POINTER): BOOLEAN is
- > do
- > c_inline_c("R=feof((FILE*)C->_input_stream);");
- > end;
- >
- diff -r lib_std/std_file.e /users/prof/colnet/SmallEiffel/lib_std/std_file.elib_std/std_file_read.e /users/prof/colnet/SmallEiffel/lib_std/std_file_read.e
- 313,323d312
- <
- < fgetc(stream_pointer : POINTER): CHARACTER is
- < -- Result is of type CHARACTER because a int is a char !
- < external "CSE"
- < alias "fgetc"
- < end;
- <
- <
- < feof(stream_ptr: POINTER): BOOLEAN is
- < external "CSE"
- < end;
- diff -r lib_std/std_file_read.e /users/prof/colnet/SmallEiffel/lib_std/std_file_read.elib_std/std_file_write.e /users/prof/colnet/SmallEiffel/lib_std/std_file_write.e
- 16,17c16
- < creation {ANY}
- < connect_to
- ---
- > creation connect_to
- 19c18
- < feature {ANY}
- ---
- > feature
- 38c37
- < feature {ANY}
- ---
- > feature
- 63c62
- < put_character(s @ i);
- ---
- > put_character(s.item(i));
- 192,193c191,193
- < fputc(c: CHARACTER; stream_pointer: POINTER): CHARACTER is
- < external "CSE"
- ---
- > tmp_string: STRING is
- > once
- > !!Result.make(512);
- 195,196d194
- <
- < tmp_string: STRING is "0123456789001234567890";
- diff -r lib_std/std_file_write.e /users/prof/colnet/SmallEiffel/lib_std/std_file_write.elib_std/std_input.e /users/prof/colnet/SmallEiffel/lib_std/std_input.e
- 40c40
- < feature {NONE}
- ---
- > feature {RUN_FEATURE}
- diff -r lib_std/std_input.e /users/prof/colnet/SmallEiffel/lib_std/std_input.elib_std/std_output.e /users/prof/colnet/SmallEiffel/lib_std/std_output.e
- 39c39
- < feature {NONE}
- ---
- > feature {RUN_FEATURE}
- diff -r lib_std/std_output.e /users/prof/colnet/SmallEiffel/lib_std/std_output.elib_std/string.e /users/prof/colnet/SmallEiffel/lib_std/string.e
- 13c13,14
- < print_on
- ---
- > print_on, fill_tagged_out_memory, eval_read_attribute,
- > eval_write_attribute
- 16,17c17
- < creation {ANY}
- < make, copy, blank
- ---
- > creation make, copy, blank, from_external
- 24c24
- < feature {ANY}
- ---
- > feature
- 32c32
- < feature {ANY} -- Creation / Modification :
- ---
- > feature -- Creation / Modification :
- 40d39
- < count := 0;
- 44,45c43
- < c_inline_c("C->_storage=(char *)%
- < %malloc((size_t)a1);");
- ---
- > storage := malloc(needed_capacity);
- 47,48c45
- < c_inline_c("C->_storage=(char *)%
- < %realloc(C->_storage,(size_t)a1);");
- ---
- > storage := realloc(storage,needed_capacity);
- 52a50
- > count := 0;
- 71c69
- < feature {ANY} -- No Modification of the receiver :
- ---
- > feature -- No Modification of the receiver :
- 79c77
- < infix "@", item(index: INTEGER): CHARACTER is
- ---
- > item, infix "@" (index: INTEGER): CHARACTER is
- 83a82
- > if storage = Void then end;
- 112c111
- < infix "<" (other: STRING): BOOLEAN is
- ---
- > infix "<" (other: like Current): BOOLEAN is
- 170d168
- < Result := false;
- 175c173
- < (i = 0) or else (not item(i).same_as(other @ i))
- ---
- > (i = 0) or else (not item(i).same_as(other.item(i)))
- 184c182
- < is_equal(other: STRING): BOOLEAN is
- ---
- > is_equal(other: like Current): BOOLEAN is
- 186,187d183
- < require else
- < true
- 288c284
- < feature {ANY} -- Modification :
- ---
- > feature -- Modification :
- 299c295
- < copy(other: STRING) is
- ---
- > copy(other: like Current) is
- 304,323c300,301
- < i := other.count;
- < count := i;
- < if i > 0 then
- < if capacity < i then
- < if capacity = 0 then
- < c_inline_c("C->_storage=(char *)%
- < %malloc((size_t)_i);");
- < else
- < c_inline_c("C->_storage=(char *)%
- < %realloc(C->_storage,(size_t)_i);");
- < end;
- < capacity := i;
- < end;
- < from
- < until
- < i = 0
- < loop
- < put(other.item(i),i);
- < i := i - 1;
- < end;
- ---
- > if capacity < other.count then
- > make(other.count);
- 324a303,311
- > from
- > i := other.count;
- > count := i;
- > until
- > i = 0
- > loop
- > put(other.item(i),i);
- > i := i - 1;
- > end;
- 356c343
- < extend(other @ i);
- ---
- > extend(other.item(i));
- 391c378
- < put(other @ i,i);
- ---
- > put(other.item(i),i);
- 402a390
- > if storage = Void then end;
- 509,519c497,503
- < count := count + 1;
- < if capacity < count then
- < if capacity = 0 then
- < capacity := 16;
- < c_inline_c("C->_storage=(char *)%
- < %malloc((size_t)C->_capacity);");
- < else
- < capacity := capacity + 16;
- < c_inline_c("C->_storage=(char *)realloc(%
- < %C->_storage,(size_t)C->_capacity);");
- < end;
- ---
- > if capacity > count then
- > elseif capacity = 0 then
- > capacity := 32;
- > storage := malloc(capacity);
- > else
- > capacity := capacity + 32;
- > storage := realloc(storage,capacity);
- 520a505
- > count := count + 1;
- 642c627
- < feature {ANY} -- Features which don't modify the string
- ---
- > feature -- Features which don't modify the string
- 658c643
- < feature {ANY} -- Conversion :
- ---
- > feature -- Conversion :
- 834c819
- < feature {ANY} -- Printing :
- ---
- > feature -- Printing :
- 837,838d821
- < local
- < i: INTEGER;
- 840,849c823,825
- < file.put_character('%"');
- < from
- < i := 1;
- < until
- < i > count
- < loop
- < file.put_character(item(i));
- < i := i +1;
- < end;
- < file.put_character('%"');
- ---
- > tagged_out_memory.clear;
- > fill_tagged_out_memory;
- > file.put_string(tagged_out_memory);
- 852c828,833
- < feature {ANY} -- Other features :
- ---
- > fill_tagged_out_memory is
- > do
- > tagged_out_memory.extend('%"');
- > tagged_out_memory.append(Current);
- > tagged_out_memory.extend('%"');
- > end;
- 853a835,836
- > feature -- Other features :
- >
- 954a938,939
- >
- > feature -- Interfacing with C string :
- 957,960c942,947
- < -- Gives address of a copy of the contents of the string
- < -- adding null character at end (for C use).
- < -- NOTE: do a malloc(`count' + 1), thus it is not an access
- < -- to `storage'.
- ---
- > -- Gives C access to the internal storage of STRING.
- > -- To be compatible with C, a null character is always
- > -- appended at the end of internal storage.
- > -- The added null character is not part of the Eiffel STRING.
- > --
- > -- NOTE: do not free/realloc the Result.
- 962,964c949,953
- < c_inline_c("R=(char *)malloc((C->_count)+1);%N%
- < %memcpy(R,C->_storage,C->_count);%N%
- < %((char *)R)[C->_count]='\0';");
- ---
- > extend('%U');
- > remove_last(1);
- > Result := storage;
- > ensure
- > Result.is_not_void
- 966c955,978
- <
- ---
- >
- > from_external(p: POINTER) is
- > -- Assume `p' is the addresse of a C string.
- > -- Initialize the string using `p'.
- > -- The null character is not part of the Eiffel STRING.
- > do
- > if storage.is_not_void then
- > free(storage);
- > end;
- > from
- > storage := p;
- > capacity := 1;
- > count := 1;
- > until
- > item(capacity) = '%U'
- > loop
- > capacity := capacity + 1;
- > count := capacity;
- > end;
- > count := count - 1;
- > ensure
- > p = to_external;
- > end;
- >
- 969c981,1006
- < tmp_string: STRING is "ABCDEFGHIJKLMN...";
- ---
- > tmp_string: STRING is
- > once
- > !!Result.make(256);
- > end;
- >
- > feature {PROC_CALL_1}
- >
- > malloc(size: INTEGER): POINTER is
- > require
- > size > 0
- > do
- > c_inline_c("R=(char*)malloc((size_t)a1);");
- > end;
- >
- > realloc(pointer: POINTER; size: INTEGER): POINTER is
- > require
- > size > 0
- > do
- > c_inline_c("R=(char*)realloc(a1,(size_t)a2);");
- > end;
- >
- > free(p: POINTER) is
- > external "C"
- > end;
- >
- > feature
- 970a1008,1035
- > eval_read_attribute(name: STRING; dest: POINTER) is
- > do
- > if ("count").is_equal(name) then
- > eval_virtual_machine.put_integer(dest,count);
- > elseif ("capacity").is_equal(name) then
- > eval_virtual_machine.put_integer(dest,capacity);
- > else
- > check
- > ("storage").is_equal(name)
- > end;
- > eval_virtual_machine.put_pointer(dest,storage);
- > end;
- > end;
- >
- > eval_write_attribute(name: STRING; source: POINTER) is
- > do
- > if ("count").is_equal(name) then
- > count := eval_virtual_machine.get_integer(source);
- > elseif ("capacity").is_equal(name) then
- > capacity := eval_virtual_machine.get_integer(source);
- > else
- > check
- > ("storage").is_equal(name)
- > end;
- > storage := eval_virtual_machine.get_pointer(source);
- > end;
- > end;
- >
- 980d1044
- <
-